<template>
	<view class="main">
		<view class="list_div">
			<view class="top">
				<image class="item_img" :src="dataList.avatar" mode=""></image>
				<view class="userInfo">
					<span>用户名：{{ dataList.name }}</span>
					<p>
						<span>预约日期：</span>
						{{ dataList.day }}
					</p>
					<p>
						<span>预约时间：</span>
						{{ dataList.time }}
					</p>
				</view>
			</view>
			<view class="reservationInfo">

				<p>
					<span>服务内容：</span>
					{{ dataList.server_content }}
				</p>
				<p>
					<span>预留电话：</span>
					{{ dataList.mobile }}
				</p>
				<p>
					<span>上门地址：</span>
					{{ dataList.address }}
				</p>
			</view>
		</view>
		<view class="btn btn_com" @click="comHandle(dataList.id)">完成</view>
		<view class="btn btn_can" @click="cancelHandle">取消</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: {}
			};
		},
		onLoad(option) {
			this.getData(option.id);
		},
		mounted() {},
		methods: {
			// 取消邀约
			async cancelHandle(item) {
				let data = {
					id: item.id
				};
				console.log(data);
				// return;
				await uni.request({
					url: '/worker/cancel_yao',
					method: 'POST',
					data,
					success: (res) => {
						if (res.code == 200) {
						} else {
							this.$wanlshop.msg(res.msg || '取消失败！');
						}
					}
				});
			},
			// 完成订单
			async comHandle(id) {
				let data = {
					id: id
				};
				console.log(data);
				// return;
				await uni.request({
					url: '/worker/success_yao',
					method: 'POST',
					data,
					success: (res) => {
						if (res.code == 200) {
						} else {
							this.$wanlshop.msg(res.msg || '取消失败！');
						}
					}
				});
			},
			// 详情数据
			async getData(id) {
				let data = {
					id
				};
				console.log(data);
				// return;
				await uni.request({
					url: '/worker/get_yao_info',
					method: 'POST',
					data,
					success: (res) => {
						if (res.res.code == 1) {
							this.dataList = res.res.data;
						} else {
							this.$wanlshop.msg(res.msg || '请求失败！');
						}
					}
				});
			}
		}
	};
</script>

<style scoped lang="less">
	.main {
		padding: 20rpx 34rpx;

		.list_div {
			height: 392rpx;
			padding: 24rpx 24rpx 40rpx;
			background-color: #fff;
			border-radius: 24rpx;
			display: flex;
			flex-direction: column;

			.top {
				display: flex;
				margin-bottom: 30rpx;

				.item_img {
					width: 144rpx;
					height: 144rpx;
					margin-right: 24rpx;
				}

				.userInfo {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					padding: 0 0 6rpx;

					span {
						font-size: 30rpx;
					}

					// .time {
					p {
						span {
							font-size: 28rpx;
							color: #999999;
						}
					}

					// }
				}
			}

			.reservationInfo {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				p {
					span {
						color: #999999;
					}
				}
			}
		}

		.btn {
			width: 100%;
			height: 88rpx;
			text-align: center;
			line-height: 88rpx;
			border-radius: 44rpx;
		}

		.btn_com {
			margin-top: 40rpx;
			background-color: #fe6601;
			color: #fff;
		}

		.btn_can {
			margin-top: 20rpx;
			background-color: #e5e5e5;
			color: #9a9a9a;
		}
	}
</style>
